package com.HomeWorkhsp.chapter14.map_;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@SuppressWarnings({"all"})
public class MapExercise {
    public static void main(String[] args) {
        Map<Integer, Staff> hashMap = new HashMap<>();
        hashMap.put(1, new Staff("xiaoming", 30000, 1));
        hashMap.put(2, new Staff("xiaohong", 10000, 2));
        hashMap.put(3, new Staff("xiaogang", 20000, 3));

        Iterator<Map.Entry<Integer, Staff>> iterator = hashMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry entry = (Map.Entry) iterator.next();
            Integer key = (Integer) entry.getKey();
            Staff staff = (Staff) entry.getValue();
            if (staff.getSalary() >= 18000){
                System.out.println(staff);
            }
        }
    }
}

class Staff {
    private String name;
    private double salary;
    private int id;

    public Staff(String name, double salary, int id) {
        this.name = name;
        this.salary = salary;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return
                "name='" + name + '\'' +
                ", salary='" + salary + '\'' +
                ", id=" + id ;
    }
}

